#
# Cookbook Name:: cobbler
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
#




if platform?("redhat", "centos", "scientific", "amazon") and node.platform_version.to_f >= 6.0

    # Install Cobbler packages
    %w{ cobbler cobbler-web debmirror pykickstart }.each do |pkg|
        package pkg do
            action :install
            options "--enablerepo=epel-testing"
        end
    end

    #Template Configuration for Cobbler
    template "/etc/cobbler/settings" do
        source "settings.erb"
        mode 0644
        owner "root"
        group "root"
        variables :cfg => node[:cobbler][:settings]
    end

    template "/etc/cobbler/modules.conf" do
        source "modules.conf.erb"
        mode 0644
        owner "root"
        group "root"
        variables :cfg => node[:cobbler][:modules]
    end

    # Register Service 
    service "cobblerd" do
        supports :restart => true, :reload => true, :status => true
        action [ :enable, :start ]
    end

end

